﻿<template>
  <section>
    <template>
      <el-table :data="data" stripe border>
        <el-table-column
          v-for="(item, index) in configs"
          :key="index"
          :label="item.label"
          :width="item.width"
          :align="item.align"
        >
          <template slot-scope="scope">
            <slot
              :row="scope.row"
              v-if="item.type == 'slot'"
              :name="item.model"
            ></slot>
            <div
              v-else
              @click="handleRouteDto(scope.row,item.model)"
              :style="{ cursor: item.model == isRouteDtoStr ? 'pointer' : 'auto' }"
            >
              {{ scope.row[item.model] }}
            </div>
          </template>
        </el-table-column>
      </el-table>
    </template>
  </section>
</template>

<script>
export default {
  name: "comTable",
  components: {},
  props: {
    data: {
      type: Array,
      default: () => {
        return [];
      },
    },
    configs: {
      type: Array,
      default: () => {
        return [];
      },
    },
    isRouteDto:{
      type:Boolean,
      default:false
    },//是否允许跳转到详情页
    isRouteDtoStr:{
      type:String,
      default:""
    },//允许跳转到详情页 的列名称
  },
  computed: {},
  watch: {},
  data() {
    return {};
  },
  mounted() {},
  methods: {
    handleRouteDto(x,v) {
      if(this.isRouteDto){
        this.$emit("path",x,v)
      }
    },
  },
};
</script>

<style scoped lang="less">
.tableBox {
}
</style>